iT邦幫忙

2024 iThome 鐵人賽

DAY 7
0
Mobile Development

從零開始學習 Jetpack Compose系列 第 7

從零開始學習 Jetpack Compose Day6 - Button

  • 分享至 

  • xImage
  •  

Button

一個與使用者進行互動的組件,透過定義按鈕的顯示與點擊事件(onClick)。可以輕鬆自定義按鈕的外觀和行為,例如調整大小、形狀、顏色,以及點擊時的效果。

https://raw.githubusercontent.com/jian-fu-hung/ithelp-2024/refs/heads/main/Images/Day6/%E6%88%AA%E5%9C%96%202024-09-21%20%E6%99%9A%E4%B8%8A10.03.28.png

Color

ButtonColors可設定四個顏色分別是
containerColor 背景顏色
contentColor 文字顏色
disabledContainerColor 停用時的背景顏色
disabledContentColor 停用時的文字顏色

可以使用ButtonDefaults.buttonColors來調整特定項目顏色或者使用ButtonDefaults.buttonColors來全部調整
https://raw.githubusercontent.com/jian-fu-hung/ithelp-2024/refs/heads/main/Images/Day6/%E6%88%AA%E5%9C%96%202024-09-21%20%E6%99%9A%E4%B8%8A10.04.11.png

Border

可設定邊框樣式。BorderStroke提供寬度以及顏色
https://raw.githubusercontent.com/jian-fu-hung/ithelp-2024/refs/heads/main/Images/Day6/%E6%88%AA%E5%9C%96%202024-09-21%20%E6%99%9A%E4%B8%8A10.11.31.png

Shape

可設定邊框形狀。RoundedCornerShape提供四個角的設定
https://raw.githubusercontent.com/jian-fu-hung/ithelp-2024/refs/heads/main/Images/Day6/%E6%88%AA%E5%9C%96%202024-09-21%20%E6%99%9A%E4%B8%8A10.12.15.png

Elevation

可設定點擊時的陰影效果
https://raw.githubusercontent.com/jian-fu-hung/ithelp-2024/refs/heads/main/Images/Day6/%E6%88%AA%E5%9C%96%202024-09-21%20%E6%99%9A%E4%B8%8A10.16.34.png


上一篇
從零開始學習 Jetpack Compose Day5 - TextField
下一篇
從零開始學習 Jetpack Compose Day7 - Image
系列文
從零開始學習 Jetpack Compose12
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言